package com.longchat;

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
@ComponentScan(basePackageClasses = App.class, useDefaultFilters = true)
public class WebAppConfig extends WebMvcConfigurerAdapter{

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//registry.addInterceptor(getLoginInterceptor()).addPathPatterns("/admin/**");
		//registry.addInterceptor(getWeixinLoginInterceptor()).addPathPatterns("/lottery/**").addPathPatterns("/question/**");
	}
	@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/**");
    }
	
	   @Bean
	    public EmbeddedServletContainerCustomizer containerCustomizer() {

	       return (container -> {
	            /*ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.htm");
	            ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.htm");
	            container.addErrorPages( error404Page, error500Page);*/
	       });
	    }

}
